import { useEffect, useState } from "react";
import { SearchProjectType } from "../pages/ProjectList/SearchProject";


// export function useDelayedValue(value:SearchProjectType["param"], time:number =200) {
export function useDelayedValue<T>(value:T, time:number =200) {
  const [result, setResult] = useState(value)

  useEffect(() => {
    let timer = setTimeout(() => {
      setResult(value)
    }, time);

    return () => {
      clearTimeout(timer)
    }
  }, [value, time])

  return result;
}
